<div>
  <p>虾米们在比什么? </p>
    <p>下载软件, 购物网站, 智能手机, 手机浏览器 .... </p>
    <p>我也要比比
      <input id="compareKeyword" type="text" value="聊天软件" size="20" />
      <input type="button" id="compareKeywordSubmit" value="确定" />
      <span var="msg"></span>
      <div id="comparing">
          <h2><div>正在比较 <span var="compareKeyword"></span></div></h2>
          <div>比较<span var="compareKeyword"></span>的
              <input type="text" id="compareItem" size="40" class="inputLine" value="易用性,安全性,界面,稳定性,方便性" /> (可用逗号分隔)<br />
              <span var="compareKeyword"></span>有 <input type="text" id="compareObj" size="40" class="inputLine" value="QQ,飞信,MSN,Gtalk,雅虎通" />
              <input type="button" id="compareButton" value="确定" /> (可用逗号分隔)</
          </div>
      </div>
</p>
</div>

<script type="text/javascript">
$(function(){
    initInput("#compareKeyword");
    initInput("#compareItem");
    initInput("#compareObj");
    setVar("compareKeyword", $("#compareKeyword").val());

    var keywordId = 0;

    $("#compareKeywordSubmit").click(function(){//提交比较对象
        var fn = function(data){
            if(data.result == true){
                keywordId = data.id;
                setVar("msg", data.msg);
                setVar("compareKeyword", $("#compareKeyword").val());
                $("#comparing").show();
            }
        }
        $.post('compare-addKeyword', {kw:getVar('compareKeyword')}, fn);
    });

    $("#compareButton").click(function(){
        $.post('compare-addItem', {itemNames:$("#compareItem").val(), keywordId:keywordId}, function(data){msgbox(data.msg)});
        $.post('compare-addObj', {objNames:$("#compareObj").val(), keywordId:keywordId}, function(data){msgbox(data.msg)});

        var items = $("#compareItem").val().split(",");
        var objs = $("#compareObj").val().split(",");

        return ;
        var tpl = '<div><label>{:objName}的{:itemName}</label><textarea id="{:itemId}" style="width:570px;height:230px"></textarea></div>';
        var html = '';
        var assign = {};
        for(i in items){
            assign = { itemName:items[i], itemId:(item + String(i))}
            html += jsTpl(tpl, assign);
        }

    });
});
</script>